Public Partial Class FrmDesafectacionOperdadorUnidad
    Inherits System.Web.UI.Page

    Private TblClientes As CapaDeNegocios.nCliente = New CapaDeNegocios.nCliente
    Private TblAfectaciones As CapaDeNegocios.nOrdenServicio = New CapaDeNegocios.nOrdenServicio
    Dim IdSolicitudInterno As String
    Dim IdClienteInterno As String

    Protected Sub Page_Load1(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Session("Login") = "Anonimo" Then
            Response.Redirect("/")
        End If

        IdSolicitudInterno = Request.QueryString("IdSolicitud")
        IdClienteInterno = Request.QueryString("IdCliente")

        If Not Page.IsPostBack Then


            IdSolicitudInterno = Request.QueryString("IdSolicitud")
            IdClienteInterno = Request.QueryString("IdCliente")
            llenarCboCliente()
            llenarGvAfectaciones()
        End If
    End Sub
    Sub llenarCboCliente()
        CboClientes.DataSource = TblClientes.Listar("", "", "", "", "", "", "", "", "", "", "", "")
        CboClientes.DataTextField = ("RazonSocial")
        CboClientes.DataValueField = ("CodigoCliente")
        CboClientes.DataBind()
    End Sub
    Sub llenarGvAfectaciones()
        If Not (CboClientes.SelectedValue = "") Then
            GvAfectaciones.DataSource = TblAfectaciones.DesafectacionUnidadOperador(CboClientes.SelectedValue)
            GvAfectaciones.DataBind()
        End If
    End Sub

    '' Protected Sub GVSolicitud_RowDataBound1(ByVal sender As System.Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GvAfectaciones.RowDataBound
    '     If e.Row.RowType = DataControlRowType.DataRow Then
    '         Dim a As LinkButton = e.Row.FindControl("LnkVer")
    '         Dim b As HiddenField = e.Row.FindControl("HFCodigoSolicitud")
    '         Dim c As Label = e.Row.FindControl("lblRazonSocial")

    '         a.OnClientClick = "javascript:window.opener.document.getElementById('" + IdSolicitudInterno + "').value = '" + b.Value.ToString() + "';window.opener.document.getElementById('" + IdClienteInterno + "').value='" + c.Text + "';window.close();"




    '     End If

    ' End Sub

    Protected Sub CboClientes_SelectedIndexChanged1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CboClientes.SelectedIndexChanged
        llenarGvAfectaciones()
    End Sub

    Protected Sub LnkAceptar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LnkAceptar.Click


        Dim i As Integer
        Dim chkDesafectar As CheckBox
        For i = 0 To GvAfectaciones.Rows.Count - 1
            Dim row As GridViewRow
            row = GvAfectaciones.Rows(i)

            chkDesafectar = row.FindControl("chkDesafectar")
            Dim OrdenServicio As Label = row.FindControl("lblNumeroOrden")
            Dim Legajo As HiddenField = row.FindControl("HFLegajo")
            Dim Unidad As HiddenField = row.FindControl("HFCodigoUnidad")
            If chkDesafectar.Checked Then
                TblAfectaciones.Desafectar(BdpFechaDesafectacion.SelectedValue, OrdenServicio.Text, Legajo.Value, Unidad.Value)
                '                Me.Response.Write("< script languaje='javascript'> window.operner.location.reload(); < / script >")
                '<script languaje='javascript'>window.parent.reload()</script>")
            End If
        Next
        'Response.Write()
        llenarGvAfectaciones()
    End Sub
End Class